package xyz.robinbingo.pfboot.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import xyz.robinbingo.pfboot.entity.HelloWorld;
import xyz.robinbingo.pfboot.repository.HelloWorldRepository;

import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

/**
 * HelloWorldController
 *
 * @author Robin
 * @date 2018/10/16 10:53
 **/
@Named
@ViewScoped
public class HelloWorldController {

    @Autowired
    private HelloWorldRepository helloWorldRepository;

    private HelloWorld helloWorld;

    public HelloWorld getHelloWorld() {
        return helloWorld;
    }

    public void setHelloWorld(HelloWorld helloWorld) {
        this.helloWorld = helloWorld;
    }

    @PostConstruct
    public void init() {
        helloWorld = helloWorldRepository.getOne(1);
    }

    public String showGreeting() {
        return "Hello " + helloWorld.getFirstName() + " " + helloWorld.getLastName() + "!";
    }
}
